package com.artron.mediaartron.data.entity;

import android.os.Parcel;
import android.os.Parcelable;

import static android.R.attr.data;

/**
 * Class description here
 *
 * @author doing
 * @version 1.0.0
 * @since 2017-10-19.
 */

public class DefaultAddressData implements Parcelable {


    /**
     * mobileCode : 189876543621
     * name : 李四
     * detail : 河北省石家庄市裕华区谈固大街
     */



    private String mobileCode;
    private String name;
    private String detail;

    private boolean isDefault;
    /**
     * id : 993eab189328447ebc8113e01aaad4cb
     */

    private String id;

    public void setAddress(AddressData address) {
        this.id = address.getId();
        this.mobileCode = address.getMobileCode();
        this.name = address.getName();
        this.detail = String.format("%s-%s-%s-%s", address.getProvinceName(),
                address.getCityName(), address.getDistrictName(), address.getDetail());
        this.isDefault = "Y".equals(address.getIsDefault());
    }

    public boolean isDefault() {
        return isDefault;
    }

    public void setDefault(boolean aDefault) {
        isDefault = aDefault;
    }

    public String getMobileCode() {
        return mobileCode;
    }

    public void setMobileCode(String mobileCode) {
        this.mobileCode = mobileCode;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.mobileCode);
        dest.writeString(this.name);
        dest.writeString(this.detail);
        dest.writeByte(this.isDefault ? (byte) 1 : (byte) 0);
        dest.writeString(this.id);
    }

    public DefaultAddressData() {
    }

    protected DefaultAddressData(Parcel in) {
        this.mobileCode = in.readString();
        this.name = in.readString();
        this.detail = in.readString();
        this.isDefault = in.readByte() != 0;
        this.id = in.readString();
    }

    public static final Parcelable.Creator<DefaultAddressData> CREATOR = new Parcelable.Creator<DefaultAddressData>() {
        @Override
        public DefaultAddressData createFromParcel(Parcel source) {
            return new DefaultAddressData(source);
        }

        @Override
        public DefaultAddressData[] newArray(int size) {
            return new DefaultAddressData[size];
        }
    };
}
